package com.weishu.house.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.weishu.house.entity.CfContract;
import com.weishu.house.service.ICfContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gao
 * @since 2021-05-25
 */
@RestController
@RequestMapping("/cf-contract")
public class CfContractController {

    @Autowired
    private ICfContractService iCfContractService;

    @RequestMapping("list")
    public PageInfo<CfContract> list(int pageNum,int pageSize,CfContract cfContract){
       /* Page page=new Page(pageNum,pageSize);*/
        PageHelper.startPage(pageNum, pageSize);
        QueryWrapper queryWrapper=new QueryWrapper();
        if (cfContract.getTenantName()!=null &&cfContract.getTenantName()!=""){
            queryWrapper.like("tenant_name",cfContract.getTenantName());
        }
        if (cfContract.getSignType()!=null){
            queryWrapper.eq("sign_type",cfContract.getSignType());
        }
        if (cfContract.getTenantPhone()!=null &&cfContract.getTenantPhone()!=""){
            queryWrapper.like("tenant_phone",cfContract.getTenantPhone());
        }
        if (cfContract.getRoomName()!=null &&cfContract.getRoomName()!=""){
            queryWrapper.like("room_name",cfContract.getRoomName());
        }
        if (cfContract.getStartDate()!=null){
            queryWrapper.eq("start_date",cfContract.getStartDate());
        }

        List<CfContract> list = iCfContractService.list(queryWrapper);
        PageInfo<CfContract> cfContractPageInfo = new PageInfo<>(list);
        return cfContractPageInfo;
    }



}
